<input type="hidden" id="new_event_status" value="<?php echo $this->session->flashdata('new_event_status'); ?>" />
<input type="hidden" id="event_event_id" value="<?php echo $this->session->flashdata('event_event_id'); ?>" />
<input type="hidden" id="event_event_hash" value="<?php echo $this->session->flashdata('event_event_hash'); ?>" />
<input type="hidden" id="event_dates" value="<?php echo urlencode($event_dates); ?>" />
<script type="text/javascript">
  $(document).ready(function() {
    load_calandar(decodeURIComponent($('#event_dates').val()));
    var new_event_status = $.trim($('#new_event_status').val());
    if (new_event_status == 1) {
      toastr.success('Successfully created event !');
    }
    if (new_event_status == 3) {
      toastr.error('Error occured. Try again !');
    }
    var event_event_id = $.trim($('#event_event_id').val());
    var event_event_hash = $.trim($('#event_event_hash').val());
    if ((event_event_id) && (event_event_hash)) {
      send_notification('new_event', event_event_id, event_event_hash);
    }
  });
</script>
<div class="page" style="min-height: 500px;">
  <div class="page-container">
    <div class="container">
      <div class="row">
        <div id="events" class="span4">
          <h4>Upcoming events</h4>
          <?php if (!empty($this_events)) { ?>
            <?php foreach ($this_events as $event) { ?>
              <?php if ($event['type'] == 1) { ?>
                <div class="event">
                  <div class="date success">
                    <h1><?php echo date('d', strtotime($event['date'])); ?></h1>
                    <h4><?php echo date('M', strtotime($event['date'])); ?></h4>
                  </div>
                  <?php if (date('d-M', strtotime($event['date'])) == date('d-M')) { ?>
                    <?php if ($this->current_user['user_id'] == $event['user_id']) { ?>
                      <a title="Goto my wall <?php echo $event['user_name']; ?>" style="text-decoration: none; float: right; color: yellowgreen; margin-right: 10px; margin-top: 5px;" href="<?php echo base_url('wall/' . $event['user_name']); ?>">[ See Wishes ]</a>
                    <?php } else { ?>
                      <a title="Its today, wish <?php echo $event['user_name']; ?>" style="text-decoration: none; float: right; color: yellowgreen; margin-right: 10px; margin-top: 5px;" href="<?php echo base_url('wall/' . $event['user_name']); ?>">[ Wish ]</a>
                    <?php } ?>
                  <?php } ?>
                  <a style="text-decoration: none;" href="<?php echo base_url('profile/' . $event['user_name']); ?>"><h4><?php echo $event['user_display_name']; ?></h4></a>
                  <p><i class="icon-gift"></i>&nbsp;Birthday</p>
                </div>
              <?php } ?>
              <?php if ($event['type'] == 2) { ?>
                <div class="event">
                  <div class="date warning">
                    <h1><?php echo date('d', strtotime($event['date'])); ?></h1>
                    <h4><?php echo date('M', strtotime($event['date'])); ?></h4>
                  </div>
                  <?php if (date('d-M', strtotime($event['date'])) == date('d-M')) { ?>
                    <?php if ($this->current_user['user_id'] == $event['user_id']) { ?>
                      <a title="Goto my wall <?php echo $event['user_name']; ?>" style="text-decoration: none; float: right; color: yellowgreen; margin-right: 10px; margin-top: 5px;" href="<?php echo base_url('wall/' . $event['user_name']); ?>">[ See Wishes ]</a>
                    <?php } else { ?>
                      <a title="Its today, wish <?php echo $event['user_name']; ?>" style="text-decoration: none; float: right; color: yellowgreen; margin-right: 10px; margin-top: 5px;" href="<?php echo base_url('wall/' . $event['user_name']); ?>">[ Wish ]</a>
                    <?php } ?>
                  <?php } ?>
                  <a style="text-decoration: none;" href="<?php echo base_url('profile/' . $event['user_name']); ?>"><h4><?php echo $event['user_display_name']; ?></h4></a>
                  <p><i class="icon-briefcase"></i>&nbsp;Joined Innovature (<?php echo time_ago($event['date']); ?>)</p>
                </div>
              <?php } ?>
              <?php if ($event['type'] == 3) { ?>
                <div class="event">
                  <div class="date danger">
                    <h1><?php echo date('d', strtotime($event['date'])); ?></h1>
                    <h4><?php echo date('M', strtotime($event['date'])); ?></h4>
                  </div>
                  <a style="text-decoration: none;" href="<?php echo base_url('profile/' . $event['user_name']); ?>"><h4><?php echo $event['user_display_name']; ?></h4></a>
                  <p style="word-break: break-all;"><i class="icon-certificate"></i>&nbsp;<?php echo substr($event['event_msg'], 0, 50) . '...'; ?></p>
                </div>
              <?php } ?>
            <?php } ?>
          <?php } else { ?>
            <div class="event">
              <div class="date">
                No more events in this month :(
              </div>
            </div>
          <?php } ?>
        </div>
        <div class="span8">
          <div class="btn-group pull-right">
            <a href="<?php echo base_url('event/myevents'); ?>" class="btn pull-right">My Events</a>
          </div>
          <div class="btn-group" style="float: right; margin-bottom: 10px;">
            <a href="<?php echo base_url('event/create'); ?>" class="btn">Create Event</a>
          </div>
          <div class="clearfix"></div>
          <div id="calendar"></div>
        </div>
      </div>
    </div>
  </div>
</div>